﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using Metro.Kashikoi.Common.ExceptionHandling;
using Microsoft.Practices.EnterpriseLibrary.Validation.Integration.WCF;
using Metro.Kashikoi.Common.Entity;
using Microsoft.Practices.EnterpriseLibrary.Validation.Validators;
using Metro.Kashikoi.ServiceContract.Location;
using Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.WCF;

namespace Metro.Kashikoi.ServiceContract.Security
{
    [ServiceContractAttribute]
    [ExceptionShielding]
   public interface ISecurityService
    {
        /// <summary>
        /// Creates the user.
        /// </summary>
        /// <param name="user">The user.</param>
        /// <returns></returns>
        [OperationContract]
        [ApplyDataContractResolver]
        [FaultContract(typeof(ServiceFault))]
        [FaultContract(typeof(ValidationFault))]
        void CreateUser(User user);

        /// <summary>
        /// Updates the user.
        /// </summary>
        /// <param name="user">The user.</param>
        [OperationContract]
        [ApplyDataContractResolver]
        [FaultContract(typeof(ServiceFault))]
        [FaultContract(typeof(ValidationFault))]
        void UpdateUser(User user);

        /// <summary>
        /// Deletes the user.
        /// </summary>
        /// <param name="Id">The id.</param>
        [OperationContract]
        [ApplyDataContractResolver]
        [FaultContract(typeof(ServiceFault))]
        [FaultContract(typeof(ValidationFault))]
        void DeleteUser([RangeValidator(0, RangeBoundaryType.Exclusive, int.MaxValue, RangeBoundaryType.Exclusive)] int id);

        /// <summary>
        /// Gets all users.
        /// </summary>
        /// <returns></returns>
        [OperationContract]
        [ApplyDataContractResolver]
        [FaultContract(typeof(ServiceFault))]
        [FaultContract(typeof(ValidationFault))]
        IList<User> GetAllUsers();

        ///// <summary>
        ///// Gets the user list.
        ///// </summary>
        ///// <param name="userIds">The user ids.</param>
        ///// <returns></returns>
        //[OperationContract]
        //[ApplyDataContractResolver]
        //[FaultContract(typeof(ServiceFault))]
        //[FaultContract(typeof(ValidationFault))]
        //IList<User> GetUserList(List<int> userIds);

        /// <summary>
        /// Gets the user list.
        /// </summary>
        /// <param name="userGroup">The user group.</param>
        /// <returns></returns>
        [OperationContract]
        [ApplyDataContractResolver]
        [FaultContract(typeof(ServiceFault))]
        [FaultContract(typeof(ValidationFault))]
        IList<User> GetUserList(int userGroupId);

        /// <summary>
        /// Gets the user group list.
        /// </summary>
        /// <param name="userGroup">The user.</param>
        /// <returns></returns>
        [OperationContract]
        [ApplyDataContractResolver]
        [FaultContract(typeof(ServiceFault))]
        [FaultContract(typeof(ValidationFault))]
        IList<UserGroup> GetUserGroupList(int userId);

        /// <summary>
        /// Gets the user by id.
        /// </summary>
        /// <param name="id">The id.</param>
        /// <returns></returns>
        [OperationContract]
        [ApplyDataContractResolver]
        [FaultContract(typeof(ServiceFault))]
        [FaultContract(typeof(ValidationFault))]
        User GetUserById(int id);

        /// <summary>
        /// Gets the user by login.
        /// </summary>
        /// <param name="login">The login.</param>
        /// <returns></returns>
        [OperationContract]
        [ApplyDataContractResolver]
        [FaultContract(typeof(ServiceFault))]
        [FaultContract(typeof(ValidationFault))]
        User GetUserByLogin(string login);

        /// <summary>
        /// Adds the route.
        /// </summary>
        /// <param name="userGroup">The user group.</param>
        /// <param name="route">The route.</param>
        [OperationContract]
        [ApplyDataContractResolver]
        [FaultContract(typeof(ServiceFault))]
        [FaultContract(typeof(ValidationFault))]
        void AddRoute(UserGroup userGroup, Region region);

        /// <summary>
        /// Removes the route.
        /// </summary>
        /// <param name="userGroup">The user group.</param>
        /// <param name="region">The region.</param>
        [OperationContract]
        [ApplyDataContractResolver]
        [FaultContract(typeof(ServiceFault))]
        [FaultContract(typeof(ValidationFault))]
        void RemoveRoute(UserGroup userGroup, Region region);

        ///// <summary>
        ///// Validates the user.
        ///// </summary>
        ///// <param name="id">The id.</param>
        ///// <param name="password">The password.</param>
        ///// <returns></returns>
        //[OperationContract]
        //[ApplyDataContractResolver]
        //[FaultContract(typeof(ServiceFault))]
        //[FaultContract(typeof(ValidationFault))]
        //bool ValidateUser(string id, string password);

        /// <summary>
        /// Mantains the GRP id.
        /// </summary>
        /// <param name="user">The user.</param>
        [OperationContract]
        [ApplyDataContractResolver]
        [FaultContract(typeof(ServiceFault))]
        [FaultContract(typeof(ValidationFault))]
        void MantainGrpId(User user);

        /// <summary>
        /// Creates the user group.
        /// </summary>
        /// <param name="userGroup">The user group.</param>
        /// <returns></returns>
        [OperationContract]
        [ApplyDataContractResolver]
        [FaultContract(typeof(ServiceFault))]
        [FaultContract(typeof(ValidationFault))]
        void CreateUserGroup(UserGroup userGroup);

        /// <summary>
        /// Updates the user group.
        /// </summary>
        /// <param name="userGroup">The user group.</param>
        [OperationContract]
        [ApplyDataContractResolver]
        [FaultContract(typeof(ServiceFault))]
        [FaultContract(typeof(ValidationFault))]
        void UpdateUserGroup(UserGroup userGroup);

        /// <summary>
        /// Deletes the user group.
        /// </summary>
        /// <param name="userGroupId">The user group id.</param>
        [OperationContract]
        [ApplyDataContractResolver]
        [FaultContract(typeof(ServiceFault))]
        [FaultContract(typeof(ValidationFault))]
        void DeleteUserGroup(int userGroupId);

        /// <summary>
        /// Gets all user groups.
        /// </summary>
        /// <returns></returns>
        [OperationContract]
        [ApplyDataContractResolver]
        [FaultContract(typeof(ServiceFault))]
        [FaultContract(typeof(ValidationFault))]
        IList<UserGroup> GetAllUserGroups();

        /// <summary>
        /// Gets the user group by id.
        /// </summary>
        /// <param name="id">The id.</param>
        /// <returns></returns>
        [OperationContract]
        [ApplyDataContractResolver]
        [FaultContract(typeof(ServiceFault))]
        [FaultContract(typeof(ValidationFault))]
        UserGroup GetUserGroupById(int id);

        /// <summary>
        /// Adds the user.
        /// </summary>
        /// <param name="user">The user.</param>
        /// <param name="userGroup">The user group.</param>
        [OperationContract]
        [ApplyDataContractResolver]
        [FaultContract(typeof(ServiceFault))]
        [FaultContract(typeof(ValidationFault))]
        void AddUserToGroup(int userId, int userGroupId);

        /// <summary>
        /// Removes the user.
        /// </summary>
        /// <param name="user">The user.</param>
        /// <param name="userGroup">The user group.</param>
        [OperationContract]
        [ApplyDataContractResolver]
        [FaultContract(typeof(ServiceFault))]
        [FaultContract(typeof(ValidationFault))]
        void RemoveUserFromGroup(int userId, int userGroupId);
    }
}
